class code2 {
    //递归
    public boolean validPalindrome(String s) {
        return valid(s,0,s.length()-1,0);
    }

    public boolean valid(String s,int left,int right,int count) {
        if(count>1) return false;
        while(left<=right) {
            if(s.charAt(left) != s.charAt(right)) {
                return valid(s,left+1,right,count+1) || valid(s,left,right-1,count+1);
            }
            left++;
            right--;
        }
        return true;
    }
}